home *** CD-ROM | disk | FTP | other *** search
- ; VECTOR ROUTINE V1.0 (C) 1990 WILDTANG PRODUCTIONS
- ; X,Y,Z ANGLES IMPLEMENTED.
- ; CHEERS TO KREATOR FOR THE FAST FORMULA, WHICH WITHOUT WE NO WAY COULD
- ; HAVE CODED THIS ROUTINE
-
-
-
- section program,code_c
- opt c-
- incdir df1:
- include gamemacros
-
-
- ; -- Local constants --
-
- rotatedpoints =$75000
-
-
- ; -- Killsystem and exit routine --
-
- bsr copyshape
- lea custom,a5
- killsys
- move.l #newcop,$dff080
- mouse:
- cmp.b #$ff,$dff006
- bne.s mouse
- BTST #$7,$BFE001
- BNE ASASAS
- ADD.W #1,SCALE
- ASASAS
- add.w #4,zrotation
- and.w #510,zrotation
- add.w #4,xrotation
- and.w #510,Xrotation
- add.w #6,Yrotation
- and.w #510,Yrotation
- bsr rotating
- bsr clearvector
- save_all
- bsr drawingthi
- return_all
- btst #6,$bfe001
- bne.s mouse
- ressys
- clr.l d0
- rts
-
-
-
- ; Blit clear the vector screen
-
- clearvector:
- blitwait
- Move.w #0,BltdMod(a5)
- move.w #%0000000100000000,BltCon0(a5)
- Move.w #$0000,BltCon1(a5)
- Move.w #$ffff,Bltalwm(a5)
- Move.w #$ffff,Bltafwm(a5)
- Move.l #$70000,Bltdpth(a5)
- Move.w #256*64+20,BltSize(a5)
- rts
-
-
- ; -- Copy vector --
- copyshape:
- lea points,a1
- lea rotatedpoints,a2
- move.w (a1),d2 .No of points
- add.w #1,d2
- mulu #6,d2
- copyloop:
- move.b (a1)+,(a2)+
- dbf d2,copyloop
- rts
-
-
- rotating
- lea rotatedpoints+2,a3
- lea points,a6
- move.w (A6)+,d7
- lea sin+64,a1 base of sine
- rotate
- move.w 0(a6),d0 x
- move.w 2(a6),d1 y
- cmp.w #0,d0
- blt misx
- sub.w scale,d0
- bra misx1
- misx
- add.w scale,d0
- misx1
- cmp.w #0,d1
- blt misy
- sub.w scale,d1
- bra misy1
- misy
- add.w scale,d1
- misy1
- move.w zrotation,d6 rotation
- bsr getsincos
- ; X1 = X COS(B)-Y SIN(A)
- ; Y1 = Y COS(B)+X SIN(A)
- move.w d0,xspace
- move.w d3,d0 y in d0
- move.w 4(a6),d1
- cmp.w #0,d1
- blt misz
- sub.w scale,d1
- bra misz1
- misz
- add.w scale,d1
- misz1
- move.w yrotation,d6 rotation
- ; Y2 = Y1 COS(B)-Z SIN(B)
- ; Z1 = Z COS(B)+Y1 SIN(B)
- bsr getsincos
- move.w d0,yspace
- move.w d3,d0
- move.w xspace,d1
- move.w xrotation,d6 rotation
- ; Z2 = Z1 COS(C)-X1 SIN(C)
- ; Z1 = X1 COS(B)+Z1 SIN(C)
- bsr getsincos
- move.w yspace,d1
- add.w #160,d0
- add.w #100,d1
- move.w d0,0(a3) x
- move.w d1,2(a3) y
- move.w d3,4(a3) z
- add.l #6,a6
- add.l #6,a3
- dbf d7,rotate
- rts
- SCALE DC.L 20
- getsincos
- move.w d0,d2 store x
- move.w d1,d3 store y
- move 64(a1,d6),d4 cosine value
- move -64(a1,d6),d5 sine value
- muls d4,d0 x cos (a)
- muls d5,d1 y sin (a)
- sub.l d1,d0 x cos (a) - y sin (a)
- add.l d0,d0 double it
- swap d0 swap it ( divu 32768 )
- muls d5,d2 x sin (a)
- muls d4,d3 y cos (a)
- add.l d2,d3 y cos (a) + x sin (a)
- add.l d3,d3 double it
- swap d3 swap it ( divu 32768 )
- rts
-
- drawingthi
- moveq #0,d7
- move.l #$70000,a0
- move.l #40,a1
- move.l #$ffffffff,a2
- move.l #Conects,a6
- move.w (a6)+,d7 Amount of conects
- lea rotatedpoints+2,a4
- drawvector
- move.w (a6)+,d5
- move.w (a4,d5),d0
- move.w 2(a4,d5),d1
- move.w (a6)+,d5
- move.w (a4,d5),d2
- move.w 2(a4,d5),d3
- movem.l d0-d7/a0-a6,-(a7)
- bsr Drawline
- movem.l (a7)+,d0-d7/a0-a6
- dbf d7,drawvector
- rts
-
- ; -- Draw line routine --
-
- ; D0 = X1
- ; D1 = Y1
- ; D2 = X2
- ; D3 = Y2
- ; A0 = BIT MAP
- ; A1 = BITPLANE WIDTH IN BYTES
- ; A2 = MASK
- ; D4 TO D6 WORK REGS
-
- DrawLine
- cmp.w d0,d2
- bne outing
- cmp.w d1,d3
- bne outing
- rts
- outing
- Move.l A1,D4
- Mulu D1,D4
- Moveq #-$10,D5
- And.w D0,D5
- Lsr.w #3,D5
- Add.w D5,D4
- Add.l A0,D4
- Clr.l D5
- Sub.w D1,D3
- roxl.b #1,D5
- tst.w d3
- Bge.s Y2gyl
- neg.w d3
- y2gyl
- sub.w d0,d2
- roxl.b #1,d5
- tst.w d2
- bge.s xtgxl
- neg.w d2
- xtgxl
- move.w d3,d1
- sub.w d2,d1
- bge.s dygdx
- exg d2,d3
- dygdx
- roxl.b #1,d5
- move.b OCtant_Table(pc,D5),d5
- Add.w d2,d2
- Lea Custom,a5
- BlitWait
- Move.w d2,bltbmod(a5)
- sub.w d3,d2
- bge.s sighn1
- or.b #$40,d5
- sighn1
- Move.w d2,bltaptl(a5)
- sub.w d3,d2
- move.w d2,bltamod(A5)
- move.w #$8000,bltadat(a5)
- move.w a2,bltbdat(a5)
- move.w #$ffff,bltafwm(a5)
- and.w #$000f,d0
- ror.w #4,d0
- or.w #$0bca,d0
- move.w d0,bltcon0(a5)
- move.w d5,bltcon1(a5)
- move.l d4,bltcpth(A5)
- move.l d4,bltdpth(A5)
- move.w a1,bltcmod(a5)
- move.w a1,bltdmod(a5)
- lsl.w #6,d3
- addq.w #2,d3
- move.w d3,bltsize(A5)
- rts
-
-
- ; -- Octants for line draw routine --
-
- Octant_Table
- dc.b 0*4+1
- Dc.b 4*4+1
- dc.b 2*4+1
- dc.b 5*4+1
- dc.b 1*4+1
- dc.b 6*4+1
- dc.b 3*4+1
- dc.b 7*4+1
- even
-
-
- ; -- New copper list example --
-
- newcop:
- cmove bplcon0,$1200
- cmove bpl1mod,$0000
- cmove bpl2mod,$0000
- cmove diwstrt,$3c81
- cmove diwstop,$3cc1
- cmove ddfstrt,$0038
- cmove ddfstop,$00d0
- cmove color00,$0000
- cmove bpl1pth,$0007
- cmove bpl1ptl,$0000
- end_copper
-
-
- ; -- Data and variables --
-
- zrotation
- dc.l 0
- xrotation
- dc.l 0
- yrotation
- dc.l 0
- xspace
- dc.l 0
- yspace
- dc.l 0
-
- ; -- Vector shapes --
-
- Points
-
- dc.w 8-1
- ; x,y,z
-
- Dc.w 50,50,50
- Dc.w -50,50,50
- Dc.w -50,-50,50
- Dc.w 50,-50,50
-
- Dc.w 50,50,-50
- Dc.w -50,50,-50
- Dc.w -50,-50,-50
- Dc.w 50,-50,-50
- Conects
-
- dc.w 12-1 Connecting points
- dc.w 0*6,1*6
- dc.w 1*6,2*6
- dc.w 2*6,3*6
- dc.w 3*6,0*6
-
- dc.w 4*6,5*6
- dc.w 5*6,6*6
- dc.w 6*6,7*6
- dc.w 7*6,4*6
-
- dc.w 0*6,4*6
- dc.w 1*6,5*6
- dc.w 2*6,6*6
- dc.w 3*6,7*6
-
- ; -- Sine table included here --
- sin:
- rept 2
- incbin misc_sources/sin
- endr
- even
-
-
-
-